import request from "@/utils/request.js";

const api_prefix = "/cart";

export function addCart(data) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/add`,
    method: "POST",
    data: data,
  });
}

export function getList(userId) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/list/${userId}`,
    method: "GET",
  });
}

export function getCartOrderList(ids) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/order/${ids}`,
    method: "GET",
  });
}

export function getOrderId(ids,userId) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/get/orderId/${ids}/${userId}`,
    method: "GET",
  });
}

export function getOrderIdFromDetail(data) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/get/detail/orderId`,
    method: "POST",
    data:data
  });
}

export function deleteCart(id) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/remove/${id}`,
    method: "DELETE",
  });
}

export function updateById(id,number) {
  return request({
    //模板字符串拼接参数
    url: `${api_prefix}/update/${id}/${number}`,
    method: "PUT",
  });
}
